home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Open Prolog 1.0.3d33 / Dialogs / Scrollbars and Popups < prev    next >
Text File  |  1996-05-02  |  4KB  |  51 lines

  1. ••Scrollbars and Popup Menus in Open Prolog dialogs.
  2.  
  3. •General
  4.  
  5. Using ResEdit (I'm assuming 2.1.3), you can add scroll bars and popup menus to a dialog. The mechanism for doing this is a bit messy, so there are one or two workarounds needed.
  6.  
  7. Scrollbars and Popup menus are called 'Controls' in ResEdit. To add either one, you need to define a new dialog item of type 'Control'. This control item refers to a CNTL resource. The CNTL resource contains a specification of the control item, including its rectangle, initial value, type (scrollbar, popup menu, etc.) and more.
  8. For a popup menu, the CNTL resource also contains the resource number of the MENU resource to be used for the popup, and it also contains the width allowed for the menu's title in the dialog item.
  9. For a scrollbar, the CNTL resource also contains the Maximum and Minimum values and the PageUp/PageDown step size, that is, the number to be subtracted/added to the current value in response to a mouse click in the PageUp/PageDown part of the scrollbar (the value subtracted/added for a click in the ScrollUp/ScrollDown arrows of a scrollbar is always 1).
  10.  
  11. •The Control Item
  12.  
  13. ResEdit will not allow you to change the size of a Control dialog item, and the default height is wrong for Popups. To work around this, you should first define the item as a User Item and set its size correctly. For Popups, experience suggests a height of 19 pixels, and the width must be wide enough to allow for a menu title (if desired) as well as the menu itself. For a scrollbar, the narrow width should be 16 pixels.
  14. Having set the size of the user item, you should next define a CNTL resource with the same bounds rectange as the user item (see the next section).
  15. When the CNTL resource has been defined, go back to the user item, change it into a Control item, enable it if you wish, and set its Resource Id reference to that of the CNTL you have just defined. (If you don't do it in the order suggested above, the rectangle sizes seem to change to default values.) 
  16.  
  17. •The CNTL Resource
  18.  
  19. The fields of a CNTL resource are used as follows:
  20.  
  21. BoundsRect - these must be exactly the same as the Control Item's rectangle.
  22.  
  23. Value - Initial Value.
  24.  
  25. Visible - True.
  26.  
  27. Max -
  28. For a Scrollbar, this is the value the control will have when the 'Thumb' is at the rightmost/bottommost position. It is an integer, (-32768 to +32767).
  29. For a Popup, this is the pixel width allowed for popup menu title to the left of the popup menu itself. It may be set to 0 if desired.
  30.  
  31. Min -
  32. For a Scrollbar, this is the value the control will have when the 'Thumb' is at the leftmost/topmost position. It is an integer, (-32768 to +32767).
  33. For a Popup, this is the MENU reference number (i.e. the resource number of the MENU resource used to define the popup menu itself).
  34.  
  35. ProcID - This identifies the kind of control. For a scrollbar, use 16; for a popup menu, use 1008.
  36.  
  37. RefCon - For a Scrollbar, this is the PageUp/PageDown step size. It will be set to 16 if you don't give a value.
  38.  
  39. Title - Invisible for a scrollbar.
  40.  
  41. •The MENU Resource
  42.  
  43. When defining the MENU resource, you need to keep in mind the following:
  44.  
  45. The menus must be 'simple' - they can't have keyboard equivalent keys, special marks or colours (!).
  46.  
  47. If the MENU resource you use corresponds to a MENU resource number of a menu in Open Prolog itself, then it seems that Open Prolog's MENU will be used instead. This appears to be a failing in the MacOS. Workaround: use MENU numbers that aren't used elsewhere (over 1000 should be OK).
  48.  
  49. •Using Scrollbars and Popups.
  50.  
  51. You can get and set the values of these controls in the normal way. For a Popup, you get and set the index number of the menu item selected. You can't yet access the menu items themselves.